package com.lanyou.esb.repository;

import java.util.List;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.Repository;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RestResource;

import com.lanyou.esb.entity.ExceptionErrorCodeSetting;

/**
 * 
 * @author ly-zengzugen
 *
 */
public interface ExceptionErrorCodeSettingRepository
		extends Repository<ExceptionErrorCodeSetting, String>, JpaSpecificationExecutor<ExceptionErrorCodeSetting> {
	@RestResource(exported = false)
	ExceptionErrorCodeSetting findByErrorCode(@Param("errorCode") String errorCode);

	long count();

	boolean exists(String id);

	@RestResource(exported = true)
	<S extends ExceptionErrorCodeSetting> S save(S entity); // could expose REST
															// API

	<S extends ExceptionErrorCodeSetting> List<S> save(Iterable<S> entities);

	@RestResource(exported = true)
	// @RequiresPermissions(value={"ExceptionErrorCodeSettingManagement:view","ExceptionErrorCodeSettingManagement:maintain"},logical=Logical.OR)
	ExceptionErrorCodeSetting findOne(String id); // could expose REST API

	ExceptionErrorCodeSetting getOne(String id);

	// 以下三个接口只能选一个暴露为REST API

	@RestResource(exported = false)
	List<ExceptionErrorCodeSetting> findAll(); // could expose REST API

	@RestResource(exported = false)
	List<ExceptionErrorCodeSetting> findAll(Sort sort); // could expose REST API

	@RestResource(exported = true)
	// @RequiresPermissions(value={"ExceptionErrorCodeSettingManagement:view","ExceptionErrorCodeSettingManagement:maintain"},logical=Logical.OR)
	Page<ExceptionErrorCodeSetting> findAll(Pageable pageable); // could expose
																// REST API

	List<ExceptionErrorCodeSetting> findAll(Iterable<String> ids);

	// 以下两个接口，要么都暴露为REST API，要么都不暴露
	@RestResource(exported = true)
	// @RequiresPermissions(value={"ExceptionErrorCodeSettingManagement:maintain"})
	void delete(String id); // could expose REST API

	@RestResource(exported = true)
	// @RequiresPermissions(value={"ExceptionErrorCodeSettingManagement:maintain"})
	void delete(ExceptionErrorCodeSetting entity); // could expose REST API

	void delete(Iterable<? extends ExceptionErrorCodeSetting> entities);

	void deleteAll();

	void flush();

	<S extends ExceptionErrorCodeSetting> S saveAndFlush(S entity);

	void deleteInBatch(Iterable<ExceptionErrorCodeSetting> entities);

	void deleteAllInBatch();

}
